package com.intel.sam.automation.core;

import java.io.IOException;

import com.sip.comserver.communication.CommunicationMessage;
import com.sip.comserver.communication.client.CommunicationClient;

public class AdaptorProxy {

    private static AdaptorProxy proxy = null;

    public CommunicationMessage invoke(final CommunicationMessage message) throws IOException, ClassNotFoundException {

        final String serverAddress = "localhost";
        final String port = "3014";
        int portValue = Integer.parseInt(port);

        final CommunicationClient client = new CommunicationClient(serverAddress, portValue);
        client.send(message);

        final CommunicationMessage outputMessage = client.read();

        return outputMessage;

    }

    public static AdaptorProxy createInstance() {

        if (null == proxy) {
            proxy = new AdaptorProxy();
        }

        return proxy;
    }

}
